package com.ihr360.payroll.model.dto.salary.report;

import com.ihr360.commons.model.entity.NumberIdWithTimeAndCompanyId;
import com.ihr360.payroll.model.base.salaryreport.ISalaryPlan;
import com.ihr360.payroll.model.dto.salary.report.embedded.AttendancePlanSnapshot;
import com.ihr360.payroll.model.dto.salary.report.embedded.PayrollConfigSnapshot;
import com.ihr360.payroll.model.dto.salary.report.embedded.SalaryPlanStaffSnapshot;
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
import com.vladmihalcea.hibernate.type.json.JsonStringType;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;

/**
 * 薪酬方案(快照记录)
 */
@Entity
@TypeDefs({
        @TypeDef(name = "json", typeClass = JsonStringType.class),
        @TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)
})
@Table(
        indexes = {@Index(name = "company_salaryPlan_index", columnList = "companyId,salaryPlanId")})
public class HistorySalaryPlan extends NumberIdWithTimeAndCompanyId<Long> implements ISalaryPlan {

    //与薪资方案id保持一致
    @Column
    private Long salaryPlanId;

    /**
     * 名称
     */
    @Column(length = 50, nullable = false)
    private String name;

    /**
     * 备注
     */
    @Column(length = 2000)
    private String remark;

    /**
     * 工资表设置快照
     */
    @Column(columnDefinition = "text", name = "payrollConfig")
    @Type(type = "json")
    private PayrollConfigSnapshot payrollConfig;

    /**
     * 考勤方案
     */
    @Column(columnDefinition = "text", name = "attendancePlan")
    @Type(type = "json")
    private AttendancePlanSnapshot attendancePlan;

    @Column(columnDefinition = "text", name = "staffs")
    @Type(type = "json")
    private SalaryPlanStaffSnapshot staffs;


    /**
     * 是否启用
     */
    private boolean enabled = true;


    /**
     * 是否每月发放一次
     */
    private boolean monthCycle = true;

    /**
     * 算薪周期月
     */
    private Integer calculateCycleMonth;

    /**
     * 算薪周期天
     */
    private Integer calculateCycleDay;

    /**
     * 考勤周期月
     */
    private Integer attendanceCycleMonth;

    /**
     * 考勤周期天
     */
    private Integer attendanceCycleDay;

    public Long getSalaryPlanId() {
        return salaryPlanId;
    }

    public void setSalaryPlanId(Long salaryPlanId) {
        this.salaryPlanId = salaryPlanId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public PayrollConfigSnapshot getPayrollConfig() {
        return payrollConfig;
    }

    public void setPayrollConfig(PayrollConfigSnapshot payrollConfig) {
        this.payrollConfig = payrollConfig;
    }

    public AttendancePlanSnapshot getAttendancePlan() {
        return attendancePlan;
    }

    public void setAttendancePlan(AttendancePlanSnapshot attendancePlan) {
        this.attendancePlan = attendancePlan;
    }

    public SalaryPlanStaffSnapshot getStaffs() {
        return staffs;
    }

    public void setStaffs(SalaryPlanStaffSnapshot staffs) {
        this.staffs = staffs;
    }

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public boolean isMonthCycle() {
        return monthCycle;
    }

    public void setMonthCycle(boolean monthCycle) {
        this.monthCycle = monthCycle;
    }

    public Integer getCalculateCycleMonth() {
        return calculateCycleMonth;
    }

    public void setCalculateCycleMonth(Integer calculateCycleMonth) {
        this.calculateCycleMonth = calculateCycleMonth;
    }

    public Integer getCalculateCycleDay() {
        return calculateCycleDay;
    }

    public void setCalculateCycleDay(Integer calculateCycleDay) {
        this.calculateCycleDay = calculateCycleDay;
    }

    public Integer getAttendanceCycleMonth() {
        return attendanceCycleMonth;
    }

    public void setAttendanceCycleMonth(Integer attendanceCycleMonth) {
        this.attendanceCycleMonth = attendanceCycleMonth;
    }

    public Integer getAttendanceCycleDay() {
        return attendanceCycleDay;
    }

    public void setAttendanceCycleDay(Integer attendanceCycleDay) {
        this.attendanceCycleDay = attendanceCycleDay;
    }
}